package com.decent.common.util.jackson;

import com.decent.common.constant.DatePatternConstant;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.ZoneId;
import java.util.Locale;
import java.util.TimeZone;

/**
 * Jackson配置,去掉时间返回前端 带 T
 *
 * @author wangyan
 */
@Configuration
public class JacksonConfiguration {

    @Bean
    public Jackson2ObjectMapperBuilderCustomizer customizer() {
        return builder -> {
            builder.locale(Locale.CHINA);
            builder.timeZone(TimeZone.getTimeZone(ZoneId.systemDefault()));
            builder.simpleDateFormat(DatePatternConstant.NORM_DATETIME_PATTERN);
            builder.modules(new JavaTimeModule(), new EnumModule());
        };
    }

}